import axios from '@/api/fetch';
//import * as types from './types';
import SERVER from '@/api/server';

const prefix = process.env.NODE_ENV === 'development' ? 'chengbowen' : SERVER.CLAIMFAC
const prefix2 = process.env.NODE_ENV === 'development' ? 'repair' : SERVER.CLAIMFAC
const prefix3 = process.env.NODE_ENV === 'development' ? 'repair' : SERVER.DMSCLOUD_REPAIR

/*预授权级别维护*/
//预授权级别查询
export const getListByPage = (params) => axios.get(`${SERVER.CLAIMFAC}/rPPreLevel/getListByPage`, { params });
export const editLevel = params => axios.put(`${SERVER.CLAIMFAC}/rPPreLevel/${params.id}`, params);
/*预授权人员维护*/
//预授权人员维护查询
export const getListEmp = (params) => axios.post(`${SERVER.CLAIMFAC}/rPPreEmp/getListByPage`, params);
//预授权人员新增
export const addEmp = params => axios.post(`${SERVER.CLAIMFAC}/rPPreEmp/saveOne`, params);
//人员修改
export const editEmp = params => axios.post(`${SERVER.CLAIMFAC}/rPPreEmp/updateById/`, params);
//人员删除
export const deleteEmp = (params) => axios.delete(`${SERVER.CLAIMFAC}/rPPreEmp/${params}`, params);
/*预授权备件维护*/
//备件查询
export const getListPart = (params) => axios.post(`${SERVER.CLAIMFAC}/rpPart/getListByPage`, params);
// export const getListPart = params => axios.post(`${SERVER.CLAIMFAC}/rpPart/getListByPage`,  params );
//备件新增
export const addPart = params => axios.post(`${SERVER.CLAIMFAC}/rpPart/saveOne`, params);
//备件查询
export const findPartClaim = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/partInfos/findPartClaim`, { params })
//备件修改
export const editPart = params => axios.post(`${SERVER.CLAIMFAC}/rpPart/updateByPtId/`, params);
//备件删除
export const deletePart = (params) => axios.delete(`${SERVER.CLAIMFAC}/rpPart/${params}`, params);
//备件导出
export const exportPart = params => axios.post(`${SERVER.CLAIMFAC}/rpPart/getListForExport`, params, { responseType: 'blob' });
//备件模板导出
export const exportPartModel = params => axios.post(`${SERVER.CLAIMFAC}/rpPart/exportModel`, params, { responseType: 'blob' });
//备件查询userid
export const selectrpPartById = params => axios.get(`${SERVER.CLAIMFAC}/rpPart/selectById/${params}`);

/*预授权工时维护*/
//工时查询
export const getListLabour = (params) => axios.post(`${SERVER.CLAIMFAC}/rPPreLabour/getListByPage`, params);
//工时新增
export const addLabour = params => axios.post(`${SERVER.CLAIMFAC}/rPPreLabour/saveOne`, params);
//工时修改
export const editLabour = params => axios.post(`${SERVER.CLAIMFAC}/rPPreLabour/updateById/`, params);
//工时删除
export const deleteLabour = (params) => axios.delete(`${SERVER.CLAIMFAC}/rPPreLabour/${params}`, params);
//工时导出
export const exportLabour = params => axios.post(`${SERVER.CLAIMFAC}/rPPreLabour/getListForExport`, params, { responseType: 'blob' });
//工时导入
// export const importLabour = params => axios.post(`${SERVER.CLAIMFAC}/rPPreLabour/importExcel`,  params );
//工时导出模板
export const exportLabourModel = params => axios.post(`${SERVER.CLAIMFAC}/rPPreLabour/exportModel`, params, { responseType: 'blob' });
//工时查询userid
export const selectrPPreLabourById = params => axios.get(`${SERVER.CLAIMFAC}/rPPreLabour/selectById/${params}`,);

/*服务管理工时维护*/
//工时查询
export const getListService = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/selectRepairItem`, { params });
//工时新增、修改（type= add edit）
export const editRepairItem = (type, params) => axios.post(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/addRepairItem/${type}`, params);
//批量处理
export const updateStatesRepairItem = (params, labourCodes) => axios.post(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/updateStatesRepairItemByLabourCode/${params.itemStuatus}`, labourCodes);
//下载
export const exportRepair = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/getWorkExport`, { params, responseType: 'blob' });
//模板导出
export const exportRepairModel = params => axios.post(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/exportRepairItem`, params, { responseType: 'blob' });
//明细
export const getRepairDetail = (params) => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/selectRepairItemByLabourCode`, { params });
//获取车型车系
export const getSeriesAndModels = (params) => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/getSeriesAndModels/${params}`);

//下发
export const sendDown = params => axios.post(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/downRepairItemByLabourCode`, params);

//获取车系
export const getCarSeries = () => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/seriesSelect`);

//获取车型
export const getCarModels = (params) => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/${params}/modelSelect`, { params });

//索赔工时维护获取车型
export const getAllCarModels = (params) => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairProject/modelSelect`, { params });


//  查询车型下拉框
export const getModelList = (brandsid, seriessid, params) => {
  const url = `${SERVER.DMSCLOUD_SYSBASEDATA}/vehicleProduct/brandsdict/${brandsid}/seriessdict/${seriessid}/modelsdict`
  return axios.get(url, {
    seriessid: seriessid,
    brandsid: brandsid,
    params: params
  })
}
